﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using KCMS.Areas.Admin.Interfaces;
using KCMS.BusinessLogic.Models;
using KCMS.BusinessLogic.Interfaces;
using StructureMap;
using System.Web.Helpers;
namespace KCMS.Areas.Admin.Engine
{
    public class ProductImagePathGenerator : IPathGenerator
    {
        private IProductService pService = ObjectFactory.GetInstance<IProductService>();
        private ProductImage ProductImage { get; set; }

        public ProductImagePathGenerator(ProductImage productImage)
            : base()
        {
            ProductImage = productImage;
        }
        public override string generatePath(WebImage image, bool thumb)
        {
            Product product = pService.getById(ProductImage.ProductId);
            String effPath = product.Article + "-" + ProductImage.Color + "-";
            if (thumb)
            {
                effPath = effPath + base.metka + "-";
            }
            effPath = effPath + image.FileName;
            return effPath;
        }
        #region"один из вариантов реализации generatePath()"
        // ProductCategory category = pCatService.getById(product.CategoryId);
        //String sex = "";
        //if (!(product.Men && product.Women))
        //{
        //    if (product.Men)
        //    {
        //        sex = "men\\";
        //    }
        //    else if (product.Women)
        //    {
        //        sex = "women\\";
        //    }
        //}
        //IEnumerable<ProductCategory> parents = pCatService.getAllParents(category);
        //String parentsPath=null;
        //foreach(ProductCategory parentCategory in parents){
        //    parentsPath = parentsPath + parentCategory.Code + "/";
        //}

        //String effPath = parentsPath + category.Code + "/"+product.Brend.Title+"/"+product.Code+product.Index+"/";
        #endregion
    }
}